//
//  LocalWeatherView.m
//  Funny
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 King. All rights reserved.
//

#import "LocalWeatherView.h"

@implementation LocalWeatherView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.titleL = [[UILabel alloc]init];
        self.titleL.font = [UIFont systemFontOfSize:19];
        self.titleL.textColor = [UIColor whiteColor];
        self.titleL.text = @"当前城市天气:";
        [self addSubview:self.titleL];
        
        self.weathLable = [[UILabel alloc]init];
        self.weathLable.font = [UIFont systemFontOfSize:15];
        self.weathLable.textColor = [UIColor whiteColor];
        [self addSubview:self.weathLable];
        
        self.cityName = [[UILabel alloc]init];
        self.cityName.textColor = [UIColor whiteColor];
        self.cityName.font = [UIFont systemFontOfSize:19];
        [self addSubview:self.cityName];
        
        self.windStyle = [[UILabel alloc]init];
        self.windStyle.font = [UIFont systemFontOfSize:15];
        self.windStyle.textColor = [UIColor whiteColor];
        [self addSubview:self.windStyle];
        
        self.dressIndex = [[UILabel alloc]init];
        self.dressIndex.font = [UIFont systemFontOfSize:12];
        self.dressIndex.numberOfLines = 2;
        self.dressIndex.textColor = [UIColor colorWithRed:0 green:220.0 / 256.0 blue:220.0 / 256.0 alpha:1.0];
        [self addSubview:self.dressIndex];
        
        self.sunIndex = [[UILabel alloc]init];
        self.sunIndex.numberOfLines = 2;
        self.sunIndex.font = [UIFont systemFontOfSize:12];
        self.sunIndex.textColor = [UIColor colorWithRed:0 green:220.0 / 256.0 blue:220.0 / 256.0 alpha:1.0];
        [self addSubview:self.sunIndex];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    WeakSelf(weakSelf);
    self.titleL.frame = CGRectMake(10, 10, 137, 30);
    self.weathLable.frame = CGRectMake(10, 40, SelfWidth + 30, 30);
    self.cityName.frame = CGRectMake(140, 10, 200, 30);
    self.windStyle.frame = CGRectMake(10, 65, SelfWidth - 30, 30);
    self.dressIndex.frame = CGRectMake(10, 100, SelfWidth - 20, 35);
    [self.sunIndex mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.dressIndex.mas_bottom);
        make.left.equalTo(weakSelf).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(SelfWidth - 20, 35));
    }];
}

- (void)setModel:(MainWeathModel *)model
{
    self.weathLable.text = [NSString stringWithFormat:@"温度: %@   湿度: %@   天气: %@",[model.weather objectForKey:@"temperature" ],[model.weather objectForKey:@"humidity"],[model.weather objectForKey:@"info"]];
    self.cityName.text = model.city_name;
    self.windStyle.text = [NSString stringWithFormat:@"风向: %@   风力: %@",[model.wind objectForKey:@"direct" ],[model.wind objectForKey:@"power"]];
}

- (void)setDic:(NSDictionary *)dic
{
    NSArray *arr = [dic objectForKey:@"chuanyi"];
    NSArray *arr1 = [dic objectForKey:@"ziwaixian"];
    self.dressIndex.text = [NSString stringWithFormat:@"穿衣建议:  %@  %@",arr[0],arr[1]];
    self.sunIndex.text = [NSString stringWithFormat:@"紫外线强度:  %@  %@",arr1[0],arr1[1]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
